#include "utils.h"

char *strcpy(char *target, const char *source)
{
	int i;

	for (i = 0; source[i] != '\0'; ++i)
		target[i] = source[i];
	target[i] = source[i];

	return target;
}

void* memcpy(void* dest, const void* src, int count)
{
	char* dst8 = (char*) dest;
	char* src8 = (char*) src;

	while (count--)
	{
		*dst8++ = *src8++;
	}
	return dest;
}

int strcmp(const char *s1, const char *s2)

{

	while ((*s1 && *s2) && (*s1++ == *s2++))
		;

	return *(--s1) - *(--s2);

}
/**************************************************************************
 * registers a function for a given interrupt vector
 **************************************************************************/
void exceptionHandler(int interruptVector, void * address)
{
	long int vector_base = 0x10000000;

	vector_base += 4 * interruptVector;

	asm( "move.l %d0, -(%a7)" );
	asm( "move.l %a1, -(%a7)" );
	asm( "move.l %0,%%d0" : :"m"(address) );
	asm( "move.l %0, %%a1" : :"m"(vector_base) );
	asm( "move.l %d0,(%a1)");
	asm( "move.l (%a7)+, %a1" );
	asm( "move.l (%a7)+, %d0" );
}

